child_graph = {"0": "1#2", "1": "3", "2": "5", "3": "4",
               "4": "2", "5": "4#6", "6": "0#2"}

visited = []
trace = []
has_circle = False


def dfs(node_index):
    global has_circle
    if (node_index in visited):
        if (node_index in trace):
            has_circle = True
            trace_index = trace.index(node_index)
            for i in range(trace_index, len(trace)):
                print(trace[i] + ' ', end='')
            print('\n', end='')
            return
        return

    visited.append(node_index)
    trace.append(node_index)

    if (node_index != ''):
        children = child_graph[node_index].split('#')
        for child in children:
            dfs(child)
    trace.pop()


dfs("1")
if (has_circle == False):
    print("No Cycle.")